home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / zmodem.arc / ZMODEM.TXT
Text File  |  1987-01-27  |  61KB  |  2,009 lines

  1.  
  2.  
  3.      The ZMODEM Asynchronous Inter Application File Transfer Protocol
  4.  
  5.                   Chuck Forsberg
  6.  
  7.                Omen Technology Inc
  8.  
  9.  
  10.                   Chuck Forsberg
  11.                Omen Technology Inc
  12.            17505-V Northwest Sauvie Island Road
  13.               Portland Oregon 97231
  14.                Voice: 503-621-3406
  15.         Modem (Telegodzilla): 503-621-3746 Speed 1200,300
  16.               Compuserve: 70715,131
  17.             UUCP: ...!tektronix!reed!omen!caf
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61. Chapter 0        rev051486 Printed 5-16-86             1
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69. Chapter 0        rev051486 Printed 5-16-86             2
  70.  
  71.  
  72.  
  73. 1.  INTENDED AUDIENCE
  74.  
  75. This document is intended for systems programmers and other technically
  76. qualified people who choose and implement asynchronous file transfer
  77. protocols over dial-up networks and related environments.
  78.  
  79.  
  80. 2.  ACKNOWLEDGMENTS
  81.  
  82. Encouragement and suggestions by Stuart Mathison, Thomas Buck, John Wales,
  83. Ward Christensen, and Irv Hoff are gratefully acknowledged.
  84.  
  85.  
  86. 3.  RELATED DOCUMENTS
  87.  
  88. The following files should be available for reference while studying this
  89. document:
  90.  
  91. YMODEM.DOC Describes the XMODEM and YMODEM file transfer protocols
  92.  
  93. ZMODEM.H Provides definitions for the manifest constants referenced
  94.     herein.
  95.  
  96. rz.c, sz.c, rbsb.c Unix source code for operating ZMODEM programs.
  97.  
  98. rz.1, sz.1 Manual pages for rz and sz.
  99.  
  100. zm.c, zmodem.h Operating system independent ZMODEM subroutines, header
  101.     file.
  102.  
  103.  
  104. 4.  ROSETTA STONE
  105.  
  106. Here are some definitions which reflect the current vernacular in the
  107. computer media.  The attempt here is identify the file transfer protocol
  108. rather than specific programs.
  109.  
  110. Frame    A ZMODEM frame consists of a header packet and 0 or more data
  111.     packets.
  112.  
  113. XMODEM  refers to the original 1979 file transfer etiquette introduced by
  114.     Ward Christensen's 1979 MODEM2 program.  It's also called the
  115.     MODEM or MODEM2 protocol.  Some who are unaware of MODEM7's
  116.     unusual batch file mode call it MODEM7.  Other aliases include
  117.     "CP/M Users's Group" and "TERM II FTP 3".  This protocol is
  118.     supported by every serious communications program because of its
  119.     universality, simplicity, and reasonable performance.
  120.  
  121. XMODEM/CRC replaces XMODEM's 1 byte checksum with a two byte Cyclical
  122.     Redundancy Check (CRC-16), giving modern error detection
  123.     protection.
  124.  
  125.  
  126.  
  127. Chapter 4        rev051486 Printed 5-16-86             2
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135. Chapter 4        rev051486 Printed 5-16-86             3
  136.  
  137.  
  138.  
  139. YMODEM  refers to the XMODEM/CRC protocol with the throughput and/or batch
  140.     transmission enhancements described in YMODEM.DOC.
  141.  
  142. ZMODEM  Zmodem is a second generation streaming protocol for text and
  143.     binary file transmission between applications running on
  144.     microcomputers and mainframes.
  145.  
  146.  
  147. 5.  WHY DEVELOP ZMODEM?
  148.  
  149. Since its development half a decade ago, the Ward Christensen MODEM
  150. protocol has enabled a wide variety of computer systems to interchange
  151. data.  There is hardly a communications program that doesn't at least
  152. claim to support this protocol, now called XMODEM.
  153.  
  154. Advances in computing, modems and networking have spread the XMODEM
  155. protocol far beyond the micro to micro environment for which it was
  156. designed.  These application have exposed some weaknesses:
  157.  
  158.    + The user interface is suitable for computer hobbyists.  Three or four
  159.      commands must be keyboarded to transfer each file.
  160.  
  161.    + The short block length causes throughput to suffer when used with
  162.      timesharing systems, packet switched networks, satellite circuits,
  163.      and buffered (error correcting) modems.
  164.  
  165.    + The 8 bit checksum and unprotected transactions allow undetected
  166.      errors and disrupted file transfers.
  167.  
  168.    + Only one file can be sent per command.  The file name has to be given
  169.      twice, first to the sending program and then again to the receiving
  170.      program.
  171.  
  172.    + The transmitted file accumulates as many as 127 extraneous bytes.
  173.  
  174.    + The modification date and other file attributes are lost.
  175.  
  176.    + XMODEM requires complete 8 bit transparency, all 256 codes.  XMODEM
  177.      will not operate over some networks that need flow control.
  178.  
  179. A number of other protocols have been developed over the years, but none
  180. have displaced XMODEM to date.
  181.  
  182.    + Lack of public domain documentation and example programs have kept
  183.      proprietary protocols such as MNP, Blast, and others tightly bound to
  184.      the fortunes of their suppliers.
  185.  
  186.    + Hardware and/or software complexity discourages the widespread
  187.      application of BISYNC, SDLC, HDLC, X.25, and X.PC protocols.
  188.  
  189.  
  190.  
  191.  
  192.  
  193. Chapter 5        rev051486 Printed 5-16-86             3
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201. Chapter 5        rev051486 Printed 5-16-86             4
  202.  
  203.  
  204.  
  205.    + Link level protocols such as X.25, X.PC, and MNP do not manage
  206.      application to application file transfers.
  207.  
  208.    + The Kermit protocol was developed to allow file transfers in
  209.      environments hostile to XMODEM.  The performance compromises
  210.      necessary to accomodate non transparent environments limit Kermit's
  211.      efficiency.  Even with completely transparent channels, Kermit
  212.      control character quoting limits the efficiency of binary file
  213.      transfers to about 75 per cent.[1]
  214.  
  215.      Kermit Sliding Windows ("SuperKermit") improves throughput over
  216.      networks at the cost of increased complexity.  SuperKermit state
  217.      transitions are encoded in a special language "wart" which requires a
  218.      C compiler.  The SuperKermit C code requires full duplex
  219.      communications and the ability to check for the presence of
  220.      characters in the input queue, precluding its implementation on some
  221.      operating systems.
  222.  
  223.      A number of submodes are used in various Kermit programs, including
  224.      different methods of transferring binary files.  Two Kermit programs
  225.      will mysteriously fail to operate with each other if these submodes
  226.      are not matched.
  227.  
  228. A number of extensions to the XMODEM protocol have been made under the
  229. collective name YMODEM.
  230.  
  231.  + YMODEM-k uses 1024 byte blocks to reduce the overhead from transmission
  232.    delays by 87 per cent compared to XMODEM, but network delays can still
  233.    degrade performance.  Some networks may not be transmit the 1024 byte
  234.    packets unmodified.
  235.  
  236.  + The handling of files that are not a multiple of 1024 or 128 bytes is
  237.    awkward, especially if the file length is not known, or changes during
  238.    transmission.
  239.  
  240.  + YMODEM-g provides efficient batch file transfers, preserving the exact
  241.    file length and file modification date.  YMODEM-g is essentially
  242.    insensitive to network delays.  Because it does not support error
  243.    recovery, YMODEM-g is usually used hardwired or with a reliable link
  244.    level protocol.  IF YMODEM-g detects a CRC error, data transfers are
  245.    aborted.  YMODEM-g is easy to implement because it closely resembles
  246.    XMODEM-CRC.
  247.  
  248. Another XMODEM "extension" is protocol cheating, referred to as "Turbo
  249. Download" and OverThruster.  [2] These sometimes improve XMODEM throughput
  250.  
  251.  
  252. __________
  253.  
  254.  1. Some Kermit programs support run length encoding.
  255.  
  256.  
  257.  
  258.  
  259. Chapter 5        rev051486 Printed 5-16-86             4
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267. Chapter 5        rev051486 Printed 5-16-86             5
  268.  
  269.  
  270.  
  271. at the expense of error recovery.
  272.  
  273. The ZMODEM Protocol is proposed as a means of addressing the weaknesses
  274. described above while maintaining as much of XMODEM's simplicity and prior
  275. art as possible.
  276.  
  277.  
  278.  
  279. 6.  ZMODEM Protocol Design Criteria
  280.  
  281. The design of a file transfer protocol is an engineering compromise
  282. between conflicting requirements:
  283.  
  284. 6.1  Ease of Use
  285.  
  286.  + ZMODEM allows either program to initiate file transfers, passing
  287.    commands and/or modifiers to the other program.
  288.  
  289.  + File names need be entered only once, menu selections are possible.
  290.  
  291.  + Wild Card names may be used with batch transfers.
  292.  
  293.  + Minimum keystrokes required to initiate transfers.
  294.  
  295.  + ZRQINIT packet sent by sending program can trigger automatic downloads.
  296.  
  297.  + ZMODEM can step down to YMODEM if the other end does not support
  298.    ZMODEM.[1]
  299.  
  300. 6.2  Throughput
  301.  
  302. ZMODEM is designed for optimum performance with minimum degradation caused
  303. by delays introduced by packet switched networks and timesharing systems.
  304.  
  305. ZMODEM is optimized for best throughput when line hits occur infrequently.
  306. This assumption markedly reduces code complexity and memory requirements.
  307. ZMODEM protocol features enhance rapid error recovery compared to network
  308. compatible XMODEM implementations.
  309.  
  310. It is assumed that many transfers will originate from a timesharing system
  311. connected to a packet switched network.  ZMODEM provides features to allow
  312. for simple, efficient implementation on timesharing hosts.
  313.  
  314.  
  315.  
  316. __________________________________________________________________________
  317.  
  318.  2. Omen Technology Trademark
  319.  
  320.  1. Provided the transmission medium accomodates YMODEM.
  321.  
  322.  
  323.  
  324.  
  325. Chapter 6        rev051486 Printed 5-16-86             5
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333. Chapter 6        rev051486 Printed 5-16-86             6
  334.  
  335.  
  336.  
  337. File transfers begin immediately regardless of which program is started
  338. first, without the 10 second delay associated with XMODEM.
  339.  
  340.  
  341. 6.3  Integrity and Robustness
  342.  
  343. All packets are protected with 16 bit CRC.  Proprietary alogrithyms[2] are
  344. not needed for reliable transfers.
  345.  
  346. A security challenge guards againgst Trojan Horse messages.
  347.  
  348. 6.4  Ease of Implementation
  349.  
  350. ZMODEM accomodates a wide variety of systems:
  351.  
  352.  + Microcomputers that cannot overlap disk and serial i/o
  353.  
  354.  + Microcomputers that cannot overlap serial send and receive
  355.  
  356.  + Computers and/or networks requiring XON/XOFF flow control
  357.  
  358.  + Computers that cannot check the serial input queue for the presence of
  359.    data without having to wait for the data to arrive.
  360.  
  361. Although ZMODEM provides "hooks" for multiple "threads", ZMODEM is not
  362. intended to replace link level protocols such as X.25.
  363.  
  364. ZMODEM accomodates network and timesharing system delays by continuously
  365. transmitting data unless the receiver interrupts the sender to request
  366. retransmission of garbled data.  ZMODEM in effect uses the entire file as
  367. a window.[3]
  368.  
  369. ZMODEM provides a general purpose application to application file transfer
  370. protocol which may be used directly or with with reliable link level
  371. protocols such as X.25, MNP, Fastlink, etc.
  372.  
  373.  
  374. 7.  ZMODEM BASICS
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382. __________
  383.  
  384.  2. Unique to Professional-YAM, PowerCom, etc.
  385.  
  386.  3. Streaming strategey is discussed in a coming chapter.
  387.  
  388.  
  389.  
  390.  
  391. Chapter 7        rev051486 Printed 5-16-86             6
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399. Chapter 7        rev051486 Printed 5-16-86             7
  400.  
  401.  
  402.  
  403. 7.1  Packetization
  404.  
  405. ZMODEM frames somewhat different from X/YMODEM blocks.  X/YMODEM blocks
  406. are not used for the following reasons:
  407.  
  408.  + Block numbers are limited to 256
  409.  
  410.  + No provision for variable length blocks
  411.  
  412.  + Line hits corrupt protocol signals, causing failed file transfers.  In
  413.    particular, modem errors sometimes generate false block numbers, false
  414.    EOTs and false ACKs.  False ACKs are the most troublesome as they cause
  415.    the sender to lose synchronization with the receiver.
  416.  
  417.    State of the art X/YMODEM programs such as Professional-YAM and
  418.    PowerCom overcome some of these weaknesses with clever proprietary
  419.    code, but a stronger protocol is desired.
  420.  
  421.  + It is difficult to determine the beginning and ends of X/YMODEM blocks
  422.    when line hits cause a loss of synchronization.  This precludes rapid
  423.    error recovery.
  424.  
  425. 7.2  Link Escape Encoding
  426.  
  427. ZMODEM acheives data transparency by extending the 8 bit character set
  428. (256 codes) with escape sequences based on the ZMODEM data link escape
  429. character ZDLE.[1]
  430.  
  431. Link Escape coding permits variable length data packets without the
  432. overhead of a separate byte count.  It allows the beginning of frames to
  433. be detected without special timing techniques, facilitating rapid error
  434. recovery.
  435.  
  436. Link Escape coding does add some overhead.  The worst case, a file
  437. consisting entirely of ZDLE characters, would incur a 50% overhead.
  438.  
  439. The ZDLE character is special.  ZDLE represents a control sequence of some
  440. sort.  If a ZDLE character appears in the data sent within a binary
  441. packet, it is prefixed with ZDLE, then sent as ZDLEE.
  442.  
  443. The value for ZDLE is octal 030 (ASCII CAN).  This particular value was
  444. chosen to allow a string of CAN characters to abort a ZMODEM session,
  445. compatible with X/YMODEM session abort.
  446.  
  447.  
  448.  
  449. __________
  450.  
  451.  1. This and other constants are defined in the zmodem.h include file.
  452.     Please note that constants with a leading 0 are octal constants in C.
  453.  
  454.  
  455.  
  456.  
  457. Chapter 7        rev051486 Printed 5-16-86             7
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465. Chapter 7        rev051486 Printed 5-16-86             8
  466.  
  467.  
  468.  
  469. Since CAN is not used for normal terminal operations, communications
  470. programs can monitor the data flow for ZDLE.  The following characters can
  471. be scanned to detect the ZRQINIT packet, the invitation to automatically
  472. download commands or files.
  473.  
  474. Two successive CAN characters will abort a ZMODEM session.  Experience
  475. with YMODEM file transfers suggests that this does not impair the
  476. robustness of the protocol.  A minimum of 8 CAN are sent, so the ZMODEM
  477. subroutines can be modified to require more successive CAN characters to
  478. signal an abort.
  479.  
  480. The receiving program will decode any sequence of ZDLE followed by a byte
  481. with bit 6 set and bit 5 reset (upper case letter, either parity) to the
  482. equivalent control character by inverting bit 6.  This allows the
  483. transmitter to escape any control character that cannot be sent by the
  484. communications medium.  The ZMODEM software currently escapes ZDLE, 021,
  485. 0221, 023, and 0223.  In addition, the receiver recognizes escapes for
  486. 0177 and 0377 should these characters need to be escaped.
  487.  
  488. 7.3  Header Packet Information
  489.  
  490. All ZMODEM frames begin with a header packet which may be sent in binary
  491. or HEX form.  ZMODEM uses a single routine to recognize binary and hex
  492. header packets.  Either form of the header packet contains the same raw
  493. information:
  494.  
  495.  + A type byte[2] Future extensions to ZMODEM may use the high order bits
  496.    of the type byte to indicate thread selection.
  497.  
  498.  + Four bytes of data indicating flags and/or numeric quantities depending
  499.    on the packet type
  500.  
  501.         Figure 1.  Order of Bytes in Header Packet
  502.  
  503.  
  504.            TYPE:  packet Type
  505.            F0: Flags least significant byte
  506.            P0: file Position least significant
  507.            P3: file Position most significant
  508.  
  509.                TYPE  F3 F2 F1 F0
  510.                --------------
  511.                TYPE  P0 P1 P2 P3
  512.  
  513.  
  514.  
  515. __________
  516.  
  517.  2. The packet types are cardinal numbers beginning with 0 to minimize
  518.     state transition table memory requirements.
  519.  
  520.  
  521.  
  522.  
  523. Chapter 7        rev051486 Printed 5-16-86             8
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531. Chapter 7        rev051486 Printed 5-16-86             9
  532.  
  533.  
  534.  
  535. 7.4  Binary Header Packet
  536.  
  537. A binary header packet is only sent by the sending program to the
  538. receiving program.
  539.  
  540. A binary header packet begins with the sequence ZPAD, ZDLE, ZBIN.
  541.  
  542. The frame type byte is ZDLE encoded.
  543.  
  544. The four position/flags bytes are ZDLE encoded.
  545.  
  546. A two byte CRC of the frame type and position/flag bytes is ZDLE encoded.
  547.  
  548. 0 or more binary data packets will follow depending on the frame type.
  549.  
  550. The function zsbhdr transmits a binary header packet.  The function
  551. zgethdr receives a binary or hex header packet.
  552.  
  553.              Figure 2.  Binary Header Packet
  554.         * * ZDLE TYPE F3/P0 F2/P1 F1/P2 F0/P3 CRC-1 CRC-2
  555.  
  556.  
  557. 7.5  HEX Header Packet
  558.  
  559. The receiver sends responses in hex header packets.  The sender also uses
  560. hex header packets when they are not followed by binary data packets.
  561.  
  562. Hex encoding is required to support XON/XOFF flow control.  The hex header
  563. receiving routine ignores flow control characters.
  564.  
  565. Use of Kermit style encoding for control and paritied characters was
  566. considered and rejected because of increased possibility of interacting
  567. with some timesharing systems's line edit functions.  Use of HEX packets
  568. from the receiving program allows control characters to be used to
  569. interrupt the sender when errors are detected.  Except for header packet
  570. types that imply data packets to follow, a HEX header packet may be used
  571. in place of a binary header packet.
  572.  
  573. A hex header packet begins with the sequence ZPAD, ZPAD, ZDLE, ZHEX.  The
  574. zgethdr routine synchronizes in the ZPAD-ZDELE sequence.  The extra ZPAD
  575. allows other parts of the program to detect a ZMODEM packet and then call
  576. zgethdr to receive the packet.
  577.  
  578. The type byte, the four position/flag bytes, and the CRC thereof are sent
  579. in hex using the character set 01234567890abcdef.  Upper case hex digits
  580. are not allowed; they false trigger X/YMODEM programs.
  581.  
  582. A carriage return, line feed, and XON are appended to the HEX header
  583. packet but are not considered to be part of it.  The CR/LF aids debugging
  584. from printouts.  The XON releases the sender from spurious XOFF flow
  585. control characters generated by line noise, a common occurrence.
  586.  
  587.  
  588.  
  589. Chapter 7        rev051486 Printed 5-16-86             9
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597. Chapter 7        rev051486 Printed 5-16-86            10
  598.  
  599.  
  600.  
  601. 0 or more ASCII Encoded data packets will follow depending on the frame
  602. type.
  603.  
  604. The function zshhdr sends a hex header packet.
  605.  
  606.                Figure 3.  HEX Header Packet
  607.        * * ZDLE TYPE F3/P0 F2/P1 F1/P2 F0/P3 CRC-1 CRC-2 CR LF XON
  608.  
  609. (TYPE, F3...F0, CRC-1, and CRC-2 are each sent as two hex digits.)
  610.  
  611.  
  612. 7.6  Binary Data Packets
  613.  
  614. Binary data packets immediately follow the associated binary header
  615. packet.  A binary data packet contains 0 to 1024 bytes of data.
  616. Recommended length values are 256 bytes below 4800 bps, 1024 above 4800
  617. bps or when the data link is known to be relatively error free.
  618.  
  619. No padding is used with binary data packets.  The data bytes are ZDLE
  620. encoded and transmitted.  A ZDLE and frameend are then sent, followed by
  621. two ZDLE encoded CRC bytes.  The CRC accumulates the data bytes and
  622. frameend.
  623.  
  624. The function zsbdata sends a binary data packet.  The function zrbdata
  625. receives a binary data packet.
  626.  
  627. 7.7  ASCII Encoded Data Packet
  628.  
  629. The format of ASCII Encoded data packets is not currently specified.
  630. These would be used for server commands, etc.
  631.  
  632.  
  633. 8.  PROTOCOL TRANSACTION OVERVIEW
  634.  
  635. As with the XMODEM recommendation, ZMODEM timing is receiver driven.  The
  636. transmitter should not time out at all, except to abort the program if no
  637. packets are received for an extended period of time, say one minute.[1]
  638.  
  639. To start a ZMODEM file transfer session, the sending program is called
  640. with the names of the desired file(s) and option(s).
  641.  
  642. The sending program sends the string "rz\r" to invoke the receiving
  643. program from a possible command mode.  The "rz" followed by carriage
  644. return activates a ZMODEM receive program or command if it were not
  645. already active.
  646.  
  647.  
  648. __________
  649.  
  650.  1. Special considerations apply when sending commands.
  651.  
  652.  
  653.  
  654.  
  655. Chapter 8        rev051486 Printed 5-16-86            10
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663. Chapter 8        rev051486 Printed 5-16-86            11
  664.  
  665.  
  666.  
  667. The sender may then display a message intended for human consumption, such
  668. as a list of the files requested, etc.
  669.  
  670. Then the sender sends a ZRQINIT packet.  The ZRQINIT packet causes a
  671. previously started receive program to send its ZRINIT packet without
  672. delay.
  673.  
  674. In an interactive or conversational mode, the receiving application may
  675. monitor the data stream for ZDLE.  The following characters may be scanned
  676. for B000000 indicating a ZRQINIT packet, a command to download a command
  677. or data.
  678.  
  679. The sending program awaits a command from the receiving program to start
  680. file transfers.  If a "C", "G", or NAK is received, an XMODEM or YMODEM
  681. file transfer is indicated, and file transfer(s) use the X/YMODEM
  682. protocol.  Note: With ZMODEM and YMODEM Batch, the sending program
  683. provides the file name, but not with XMODEM.
  684.  
  685. When the ZMODEM receive program starts, it immediately sends a ZRINIT
  686. packet to initiate ZMODEM file transfers, or a ZCHALLENGE packet to verify
  687. the sending program.  The receive program resends its packet at repsonse
  688. time intervals for a suitable period of time (40 seconds typical) before
  689. falling back to X/YMODEM protocol.  If the receiving program receives a
  690. ZRQINIT packet, it resends the ZRINIT packet.  If the sending program
  691. receives the ZCHALLENGE packet, it places the data in ZP0...ZP3 in an
  692. answering ZACK packet.
  693.  
  694. If the receiving program receives a ZRINIT packet, it is an echo
  695. indicating that the sending program is not operational.
  696.  
  697. Eventually the sending program correctly receives the ZRINIT packet.
  698.  
  699. The sender may then respond with an optional ZSINIT frame to set the
  700. receiving program's Attention string.  The receiver sends a ZACK packet in
  701. response, containing the serial number of the receiving program, or 0.
  702.  
  703. The sender then sends a ZFILE header with ZMODEM Conversion, Management,
  704. and Transport options[2] followed by a ZCRCW data packet containing the
  705. file name, file length, modification date, and other information identical
  706. to that used by YMODEM Batch.
  707.  
  708. The receiving program should insure the pathname and options are
  709. compatible with its operating environment and local security requirements.
  710.  
  711.  
  712.  
  713.  
  714. __________
  715.  
  716.  2. See below, under ZFILE packet type.
  717.  
  718.  
  719.  
  720.  
  721. Chapter 8        rev051486 Printed 5-16-86            11
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729. Chapter 8        rev051486 Printed 5-16-86            12
  730.  
  731.  
  732.  
  733.        If the receiver has a file with the same name and length,
  734.        it may respond with a ZCRC packet, which requires the
  735.        sender to permorm a 16 bit CRC on the file and transmit the
  736.        CRC in ZP0...ZP1 of a ZCRC packet.  The receiver uses this
  737.        information to determine whether to accept the file or skip
  738.        it.  This sequence is triggered by the ZMCRC Management
  739.        Option.
  740.  
  741. The receiver may then respond with a ZSKIP packet, which causes the
  742. sender to process the next file (if any) in the batch.
  743.  
  744. A ZRPOS packet from the receiver initiates transmission of the file data
  745. starting at the offset in the file specified in the ZRPOS packet.
  746. Normally the receiver specifies the data transfer begin begin at offset 0
  747. in the file.
  748.        The receiver may start the transfer further down in the
  749.        file.  This allows a file transfer interrupted by a loss
  750.        or carrier or system crash to be completed on the next
  751.        connection without requiring the entire file to be
  752.        retransmitted.[3] If downloading a file from a timesharing
  753.        system that becomes sluggish, the transfer can be
  754.        interrupted and resumed later with no loss of data.
  755.  
  756. The sender sends a ZDATA binary header packet (with file position)
  757. followed by one or more data packets.
  758.  
  759. The receiver compares the file position in the ZDATA header with the
  760. number of characters successfully received to the file.  If they do not
  761. agree, a ZRPOS error response is generated to force the sender to the
  762. right position within the file.[4]
  763.  
  764. A data packet terminated by ZCRCGO and CRC does not elicit a response
  765. unless an error is detected; more data packet(s) follow immediately.
  766.  
  767.        ZCRCQ data packets expect a ZACK response (with the file
  768.        offset) if no error, otherwise a ZRPOS response (with the
  769.        last good file offset).  Another data packet continues
  770.        immediately.  ZCRCQ packets are not used if the receiver
  771.        does not indicate FDX ability with the CANFDX bit.
  772.  
  773. ZCRCW data packets expect a response before the next frame is sent.  If
  774. the receiver does not indicate overlapped I/O capability with the
  775.  
  776.  
  777. __________
  778.  
  779.  3. This does not apply to files that have been translated.
  780.  
  781.  4. If the ZMSPARS option is used, the receiver instead seeks to position
  782.     in the ZDATA packet.
  783.  
  784.  
  785.  
  786.  
  787. Chapter 8        rev051486 Printed 5-16-86            12
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795. Chapter 8        rev051486 Printed 5-16-86            13
  796.  
  797.  
  798.  
  799. CANOVIO bit, or by setting a buffer size, the sender uses the ZCRCW to
  800. allow the receiver to write its buffer before sending more data.
  801.  
  802.        A zero length data frame may be used as a sending idle
  803.        packet to prevent the receiver from timing out in case
  804.        data is not immediately available to the sender.
  805.  
  806. In the absence of fatal error, the sender eventually encounters end of
  807. file.  If the end of file is encountered within a frame, the frame is
  808. closed with a ZCRCE data packet which does not elicit a response
  809. except in case of error.
  810.  
  811. The sender sends a ZEOF packet with the file ending offset equal to
  812. the number of characters in the file.  The receiver compares this
  813. number with the number of characters received.  If the receiver has
  814. received all of the file, it closes the file.  If the file close was
  815. satisfactory, the receiver responds with ZRINIT.  If the receiver has
  816. not received all the bytes of the file, the receiver sends ZRPOS with
  817. the current file offset, forcing the sender to resend the missing
  818. data.  (If the receiver cannot properly close the file, a ZFERR packet
  819. is sent.)
  820.  
  821.        After all files are processed, any further protocol
  822.        errors should not prevent the sending program from
  823.        returning with a success status.
  824.  
  825. The sender closes the session with a ZEXIT header packet.  The
  826. receiver acknowledges this with its own ZEXIT packet.
  827.  
  828. When the sender receives the acknowledging packet, it sends two
  829. characters, "OO" (Over and Out) and exits to the operating system or
  830. application that invoked it.  The receiver waits briefly for the "O"
  831. characters, then exits whether they were received or not.
  832.  
  833. 8.1  Session Cancel Packet
  834.  
  835. The Cancel packet consists of two ZPAD characters, eight CAN
  836. characters, and an optional ten backspace characters.  First, the
  837. Attn sequence is executed if the receiving program has been receiving
  838. data in streaming mode.  The ZPAD characters allow sending programs
  839. that sample the reverse data stream to check for a single character
  840. code indicating a packet from the receiver.  The trailing backspace
  841. characters attempt to erase the effects of the other characters if
  842. they are received by a command interpreter.
  843.  
  844.     static char canistr[] = {
  845. ZPAD,ZPAD,24,24,24,24,24,24,24,24,8,8,8,8,8,8,8,8,8,8,0        };
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853. Chapter 9        rev051486 Printed 5-16-86            13
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861. Chapter 9        rev051486 Printed 5-16-86            14
  862.  
  863.  
  864.  
  865. 9.  ZMODEM STREAMING TECHNIQUES
  866.  
  867. ZMODEM allows choices of several data streaming methods selected
  868. according to the limitations of the sending environment, receiving
  869. environment, and transmission channel(s).
  870.  
  871.  
  872. 9.1  Full Streaming with Sampling
  873.  
  874. If the computers can overlap serial I/O with disk I/O, and if the
  875. sender can sample the reverse channel for the presence of data
  876. without having to wait, full streaming can be used with no Attn
  877. sequence required.  The sender begins data transmission with a ZDATA
  878. header and continuous ZCRCG data packets.  When the receiver detects
  879. an error, it executes the Attn sequence and then sends a ZRPOS packet
  880. to force the sender back to the correct position within the file.  At
  881. the end of each transmitted packet, the sender checks for the
  882. presence of an error packet from the receiver.  To do this, the
  883. sender may sample the reverse data stream for the presence of a ZPAD
  884. character.
  885.  
  886. Such a program would sample the reverse channel for ZPAD.  If seen,
  887. an empty ZCRCW data packet is sent (in case the receiver was still
  888. reading packets) and then the receiver's response packet is read and
  889. acted upon.  The code fragment in sz.c beginning at NOTDEF_DOS would
  890. perform this function.
  891.  
  892.  
  893. 9.2  Full Streaming with Interrupt
  894.  
  895. The method above cannot be used if if the reverse data stream cannot
  896. be sampled without entering an I/O wait.  An alternate method is to
  897. instruct the receiver to interrupt the sending program when an error
  898. is detected.
  899.  
  900. The receiver can interrupt the sender with a control character, break
  901. signal, or combination thereof, as specified in the ZSINIT frame sent
  902. by the sending program.
  903.  
  904. When the sending program "catches" this interrupt, it reads a HEX
  905. packet (normally ZRPOS) from the receiver and takes appropriate
  906. action.  The Unix sb.c program uses a setjmp/longjmp call and the
  907. getinsync() function to read the receiver's error packet and take
  908. appropriate action.
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919. Chapter 9        rev051486 Printed 5-16-86            14
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927. Chapter 9        rev051486 Printed 5-16-86            15
  928.  
  929.  
  930.  
  931. 9.3  Full Streaming with a Sliding Window
  932.  
  933. If none of the above methods is applicable, hope is not yet lost.  If
  934. the sender can buffer responses from the receiver, the sender can use
  935. ZCRCQ packets to get ACKs from the receiver without interrupting the
  936. transmission of data.  After a sufficient number of ZCRCQ packets
  937. have been sent, the sender can read one of the one or more packets
  938. that should have arrived in it's receive interrupt buffer.
  939.  
  940. A problem with this method is the probability of wasting an excessive
  941. amount of time responding to the receiver's error packet.
  942.  
  943. 9.4  No Streaming
  944.  
  945. If the receiver cannot overlap serial and disk I/O, it uses the
  946. ZRINIT frame to specify a buffer length which the sender will not
  947. overflow.  The sending program sends a ZCRCW packet and waits for an
  948. ZACK packet before sending the next segment of the file.
  949.  
  950. If the sending program supports reverse data stream sampling or
  951. interrupt, error recovery will be faster (on average) than a protocol
  952. (such as YMODEM) that sends "monolithic" blocks.
  953.  
  954.  
  955. 10.  ATTENTION SEQUENCE
  956.  
  957. The receiving program sends the Attn sequence whenever it detects an
  958. error and needs to interrupt the sending program.
  959.  
  960. The default Attn string value is empty (no Attn sequence).  The
  961. receiving program resets Attn to the empty default before each
  962. transfer session.
  963.  
  964. The sender speficies the Attn sequence in its optional ZSINIT frame.
  965. The Attn string is terminated with a null.
  966.  
  967. Two meta-characters perform special functions:
  968.  
  969.    + \335 (octal) Sends a break signal
  970.  
  971.    + \336 (octal) Pauses one second
  972.  
  973.  
  974. 11.  PACKET/FRAME TYPES
  975.  
  976. The numeric values for the values shown in boldface are given in
  977. zmodem.h.
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985. Chapter 11        rev051486 Printed 5-16-86            15
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993. Chapter 11        rev051486 Printed 5-16-86            16
  994.  
  995.  
  996.  
  997. 11.1  ZRQINIT
  998.  
  999. Sent once by the sending program, to trigger the receiving program to
  1000. send its ZRINIT packet.  This aviods the aggravatimg startup delay
  1001. associated with XMODEM and Kermit transfers.
  1002.  
  1003. ZF0 contains ZCOMMAND if the program is attempting to send a command,
  1004. 0 otherwise.
  1005.  
  1006. 11.2  ZRINIT
  1007.  
  1008. Sent by the receiving program.  ZF0 and ZF1 contain the  bitwise or
  1009. of the receiver capability flags:
  1010. #define CANFDX  1 /* Rx can send and receive FDX */
  1011. #define CANOVIO 2 /* Rx can receive during disk I/O */
  1012. #define CANBRK  4 /* Rx can send a break signal */
  1013. #define CANCRY  8 /* Receiver can decrypt */
  1014.  
  1015. ZP0 and ZP1 contain the size of the receiver's buffer in bytes, or 0
  1016. if nonstop I/O is allowed.
  1017.  
  1018. 11.3  ZSINIT
  1019.  
  1020. Sender sends capability flags (currently all 0) (none currently
  1021. defined) followed by a binary data packet terminated with ZCRCW.  The
  1022. data packet contains the null terminated Attn sequence, maximum
  1023. length 32 bytes including the terminating null.
  1024.  
  1025. 11.4  ZACK
  1026.  
  1027. Acknowedgement to ZSINIT header packet, ZCHALLENGE header packet, or
  1028. ZCRCW data packet.  ZP0 to ZP3 contain file offset.  Response to
  1029. ZCHALLENGE contains the same 32 bits as received.
  1030.  
  1031. 11.5  ZFILE
  1032.  
  1033. This packet denotes the beginning of a file transmission attempt.
  1034. ZF0, ZF1, and ZF2 may contain options.  A value of 0 in each of these
  1035. bytes implies no special treatment.  If options are specified to the
  1036. reciever, they override options specified to the sender with the
  1037. exception of the ZCBIN option, which overrides any other Conversion
  1038. Option.
  1039.  
  1040.  
  1041. 11.5.1  ZF0: Conversion Option
  1042. If the receiver does not recognize the Conversion Option, an
  1043. application dependent default conversion may apply.
  1044.  
  1045. ZCBIN "Binary" transfer - inhibit conversion unconditionally
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051. Chapter 11        rev051486 Printed 5-16-86            16
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059. Chapter 11        rev051486 Printed 5-16-86            17
  1060.  
  1061.  
  1062.  
  1063. ZCNL Convert received end of line to local end of line convention.
  1064.      The suported end line conventions are CR/LF (most ASCII based
  1065.      operating systems except Unix and Macintosh), and NL (Unix).
  1066.      Neither of these two end of line conventions violate the
  1067.      permissible ASCII definitions for Carriage Return and Line
  1068.      Feed/New Line.
  1069.  
  1070. ZCRECOV Recover interrupted file transfer; start transfer at location
  1071.      corresponding to the receiver's end of file.  This option does
  1072.      not apply if the source file is shorter.  Files that have been
  1073.      converted (e.g., ZCNL) or subject to a single ended Transport
  1074.      Option cannot have their transfers recovered.
  1075.  
  1076. 11.5.2  ZF1: Management Option
  1077. If the receiver does not recognize the Management Option, the file
  1078. should be transferred normally.
  1079.  
  1080. ZMNEW Compare the source and destination files.  Transfer file if
  1081.      source newer or different length
  1082.  
  1083. ZMCRC Compare the source and destination files.  Transfer if
  1084.      different file length or CRC
  1085.  
  1086. ZMAPND Append source file contents to existing destination file (if
  1087.      any)
  1088.  
  1089. ZMCLOB Replace existing destination file (if any)
  1090.  
  1091. ZTSPARS Special processing for sparse file; each file segment is
  1092.      transmitted as a separate frame, where the frames are not
  1093.      necessarily contiguous.
  1094.  
  1095. 11.5.3  ZF2: Transport Option
  1096. If the receiver does not implement the particular transport option,
  1097. the file is copied without conversion for later processing.
  1098.  
  1099. ZTLZW Lempel-Ziv compression.  Transmitted data will be identical to
  1100.      that produced by compress 4.0 operating on a computer with VAX
  1101.      byte ordering, using 12 bit encoding.
  1102.  
  1103. ZTCRYPT Encryption.  An initial null terminated string identifies the
  1104.      key.  Details to be determined.
  1105.  
  1106. ZTRLE Run Length encoding Details to be determined.
  1107.  
  1108. A ZCRCW data packet follows with file name, file length, modification
  1109. date, and other information described in a later chapter.
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117. Chapter 11        rev051486 Printed 5-16-86            17
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125. Chapter 11        rev051486 Printed 5-16-86            18
  1126.  
  1127.  
  1128.  
  1129. 11.6  ZSKIP
  1130.  
  1131. Sent by the receiver in response to ZFILE, makes the sender skip to
  1132. the next file.
  1133.  
  1134. 11.7  ZNAK
  1135.  
  1136. Indicates last packet header was garbled.  (See also ZRPOS).
  1137.  
  1138. 11.8  ZABORT
  1139.  
  1140. Sent by receiver to terminate batch file transfers when requested by
  1141. the user.  Sender initiates a ZFIN sequence.[1]
  1142.  
  1143. 11.9  ZFIN
  1144.  
  1145. Sent by sending program to terminate a ZMODEM session.  Receiver
  1146. responds with ZFIN.
  1147.  
  1148. 11.10  ZRPOS
  1149.  
  1150. Sent by receiver to force file transfer to resume at file offset
  1151. given in ZP0...ZP3.
  1152.  
  1153. 11.11  ZDATA
  1154.  
  1155. ZP0...ZP3 contain file offset.  One or more data packets follow.
  1156.  
  1157. 11.12  ZEOF
  1158.  
  1159. Sender reports End of File.  ZP0...ZP3 contain the ending file
  1160. offset.
  1161.  
  1162. 11.13  ZFERR
  1163.  
  1164. Error in reading or writing file, protocol equivalent to ZABORT.
  1165.  
  1166. 11.14  ZCRC
  1167.  
  1168. Request (receiver) and response (sender) for file CRC.  ZP0 and ZP1
  1169. contain 16 bit file CRC.
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176. __________
  1177.  
  1178.  1. Or ZCOMPL in case of server mode.
  1179.  
  1180.  
  1181.  
  1182.  
  1183. Chapter 11        rev051486 Printed 5-16-86            18
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191. Chapter 11        rev051486 Printed 5-16-86            19
  1192.  
  1193.  
  1194.  
  1195. 11.15  ZCHALLENGE
  1196.  
  1197. Request to echo a random number in ZP0...ZP3 in a ZACK frame.  Sent
  1198. by the receiving program to the sending program to verify that it is
  1199. connected to an operating program, and was not activated by spurious
  1200. data or a Trojan Horse message.
  1201.  
  1202. 11.16  ZCOMPL
  1203.  
  1204. Request now completed.
  1205.  
  1206. 11.17  ZCAN
  1207.  
  1208. This is a pseudo frame type returned by gethdr() in response to a
  1209. Cancel sequence.
  1210.  
  1211. 11.18  ZFREECNT
  1212.  
  1213. Sending program requests a ZACK frame with ZP0...ZP3 containing the
  1214. number of free bytes on the current file system.  A value of 0
  1215. represents an indefinite amount of free space.
  1216.  
  1217. 11.19  ZCOMMAND
  1218.  
  1219. ZCOMMAND is only sent as a binary header packet.  ZP0...ZP2 contain a
  1220. unique cardinal number to differentiate this command from other
  1221. commands[2].  ZF0 contains 0 or ZCACK1.
  1222.  
  1223.  
  1224. A ZCRCW data packet follows, with the ASCII text command string
  1225. terminated with a NULL character.  If the command is intended to be
  1226. executed by the operating system hosting the receiving program (e.g.,
  1227. "shell escape"), it must have "!" as the first character.  Otherwise
  1228. the command is meant to be executed by the application program which
  1229. received the command.
  1230.  
  1231. If ZF0 contained ZCACK1, the receiver immediately responds with a
  1232. ZCOMPL header.  Otherwise, the receiver responds with a ZCOMPL header
  1233. when the operation is completed.
  1234.  
  1235. The exit status of the completed command is stored in ZP0...ZP3 (0 if
  1236. ZCACK1).  A 0 exit status implies nominal completion of the command.
  1237.  
  1238. If the command caused a file to be transmitted, the command sender
  1239. will see a ZRQINIT frame from the other computer attempting to send
  1240.  
  1241.  
  1242. __________
  1243.  
  1244.  2. Currently unused.
  1245.  
  1246.  
  1247.  
  1248.  
  1249. Chapter 11        rev051486 Printed 5-16-86            19
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257. Chapter 11        rev051486 Printed 5-16-86            20
  1258.  
  1259.  
  1260.  
  1261. data.
  1262.  
  1263. The sender examines ZF0 of the received ZRQINIT packet to determine
  1264. it is not an echo of its own ZRQINIT packet.  It is illegal for the
  1265. sending program to command the receiving program to send a command.
  1266.  
  1267.  
  1268.  
  1269. 12.  TRANSACTION EXAMPLE
  1270.  
  1271. 12.1  A simple file transfer
  1272.  
  1273. A simple transaction, one file, no errors, no CHALLENGE, overlapped
  1274. I/O:
  1275.  
  1276. Sender        Receiver
  1277.  
  1278. "rz\r"
  1279. ZRQINIT(0)
  1280.         ZRINIT
  1281. ZFILE
  1282.         ZRPOS
  1283. ZDATA data ...
  1284. ZEOF
  1285.         ZRINIT
  1286. ZFIN
  1287.         ZFIN
  1288. OO
  1289.  
  1290.  
  1291. 12.2  Challenge and Command Download
  1292.  
  1293.  
  1294. Sender        Receiver
  1295.  
  1296. "rz\r"
  1297. ZRQINIT(ZCOMMAND)
  1298.         ZCHALLENGE(rnd)
  1299. ZACK(same-rnd)
  1300.         ZRINIT
  1301. ZCOMMAND
  1302.         (Perform Command)
  1303.         ZCOMPL
  1304. ZFIN
  1305.         ZFIN
  1306. OO
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315. Chapter 13        rev051486 Printed 5-16-86            20
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323. Chapter 13        rev051486 Printed 5-16-86            21
  1324.  
  1325.  
  1326.  
  1327. 13.  ZFILE FRAME FILE INFORMATION
  1328.  
  1329. ZMODEM sends the same file information with the ZFILE frame data that
  1330. YMODEM Batch sends in its block 0.
  1331.  
  1332. N.B.: Only the pathname (file name) part is required for batch
  1333. transfers.
  1334.  
  1335. Pathname The pathname (conventionally, the file name) is sent as a
  1336.      null terminated ASCII string.  This is the filename format used
  1337.      by the handle oriented MSDOS(TM) functions and C library fopen
  1338.      functions.  An assembly language example follows:
  1339.                DB       'foo.bar',0
  1340.      No spaces are included in the pathname.  Normally only the file
  1341.      name stem (no directory prefix) is transmitted unless the sender
  1342.      has selected YAM's f option to send the full relative pathname.
  1343.      The source drive designator (A:, B:, etc.) is not sent.
  1344.  
  1345.      Filename Considerations:
  1346.  
  1347.     + File names should be translated to lower case unless the
  1348.       sending system supports upper/lower case file names.  This
  1349.       is a convenience for users of systems (such as Unix) which
  1350.       store filenames in upper and lower case.
  1351.  
  1352.     + The receiver should accommodate file names in lower and
  1353.       upper case.
  1354.  
  1355.     + The rb(1) program on Unix systems normally translates the
  1356.       filename to lower case unless one or more letters in the
  1357.       filename are already in lower case.
  1358.  
  1359.     + When transmitting files between different operating
  1360.       systems, file names must be acceptable to both the sender
  1361.       and receiving operating systems.
  1362.  
  1363.      If directories are included, they are delimited by /; i.e.,
  1364.      "subdir/foo" is acceptable, "subdir\foo" is not.
  1365.  
  1366. Length The file length and each of the succeeding fields are
  1367.      optional.[1] The length field is stored as a decimal string
  1368.      counting the number of data bytes in the file.
  1369.  
  1370.      With ZMODEM, the receiver uses the file length only for display
  1371.      (progress reporting) purposes; the actual length is determined
  1372.  
  1373.  
  1374. __________
  1375.  
  1376.  1. Fields may not be skipped.
  1377.  
  1378.  
  1379.  
  1380.  
  1381. Chapter 13        rev051486 Printed 5-16-86            21
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389. Chapter 13        rev051486 Printed 5-16-86            22
  1390.  
  1391.  
  1392.  
  1393.      by the data transfer.
  1394.  
  1395. Modification Date A single space separates the modification date from
  1396.      the file length.
  1397.  
  1398.      The mod date is optional, and the filename and length may be
  1399.      sent without requiring the mod date to be sent.
  1400.  
  1401.      The mod date is sent as an octal number giving the time the
  1402.      contents of the file were last changed measured in seconds from
  1403.      Jan 1 1970 Universal Coordinated Time (GMT).  A date of 0
  1404.      implies the modification date is unknown and should be left as
  1405.      the date the file is received.
  1406.  
  1407.      This standard format was chosen to eliminate ambiguities arising
  1408.      from transfers between different time zones.
  1409.  
  1410.      Two Microsoft blunders complicate the use of modification dates
  1411.      in file transfers with MSDOS(TM) systems.  The first is the lack
  1412.      of timezone standardization in MS-DOS.  A file's creation time
  1413.      can not be known unless the timezone of the system that wrote
  1414.      the file[2] is known.  Unix solved this problem (for planet
  1415.      Earth, anyway) by stamping files with Universal Time (GMT).
  1416.      Microsoft would have to include the timezone of origin in the
  1417.      directory entries, but does not.  Professional-YAM gets around
  1418.      this problem by using the z parameter which is set to the number
  1419.      of minutes local time lags GMT.  For files known to originate
  1420.      from a different timezone, the -zT option may be used to specify
  1421.      T as the timezone for an individual file transfer.
  1422.  
  1423.      The second problem is the lack of a separate file creation date
  1424.      in DOS.  Since some backup schemes used with DOS rely on the
  1425.      file creation date to select files to be copied to the archive,
  1426.      back-dating the file modification date could interfere with the
  1427.      safety of the transferred files.  For this reason,
  1428.      Professional-YAM does not modify the date of received files with
  1429.      the header information unless the d parameter is non zero.
  1430.  
  1431.  
  1432. Mode A single space separates the file mode from the modification
  1433.      date.  The file mode is stored as an octal string.  Unless the
  1434.      file originated from a Unix system, the file mode is set to 0.
  1435.      rb(1) checks the file mode for the 0x8000 bit which indicates a
  1436.      Unix type regular file.  Files with the 0x8000 bit set are
  1437.      assumed to have been sent from another Unix (or similar) system
  1438.  
  1439.  
  1440. __________
  1441.  
  1442.  2. Not necessarily that of the transmitting system!
  1443.  
  1444.  
  1445.  
  1446.  
  1447. Chapter 13        rev051486 Printed 5-16-86            22
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455. Chapter 13        rev051486 Printed 5-16-86            23
  1456.  
  1457.  
  1458.  
  1459.      which uses the same file conventions.  Such files are not
  1460.      translated in any way.
  1461.  
  1462.  
  1463. Serial Number A single space separates the serial number from the
  1464.      file mode.  The serial number of the transmitting program is
  1465.      stored as an octal string.  Programs which do not have a serial
  1466.      number should omit this field, or set it to 0.  The receiver's
  1467.      use of this field is optional.
  1468.  
  1469. The file information is terminated by a null.  If only the pathname
  1470. is sent, the pathname will be terminated by two nulls.  The length of
  1471. the file information packet, including the trailing null, must not
  1472. exceed 1024 bytes; a typical length is less than 64 bytes.
  1473.  
  1474.  
  1475. 14.  PERFORMANCE RESULTS
  1476.  
  1477. 14.1  Throughput
  1478.  
  1479. Between two single task PC-XT computrers, on a Telenet link through
  1480. the local Telenet, SuperKermit gave 72 ch/sec throughput at 1200
  1481. baud.  YMODEM-k yielded 85 chars/sec, and ZMODEM provided 113 chat
  1482. sec.  ZMODEM was not measured, but would have given much less.
  1483.  
  1484. 14.2  Error Recovery
  1485.  
  1486. Some tests of ZMODEM protocol performance have been made.  A PC-AT
  1487. with SCO SYS V Xenix or DOS 3.1 was connected to a PC with DOS 2.1
  1488. either directly at 9600 bps or with unbuffered dial-up 1200 bps
  1489. modems.  The ZMODEM software was configured to use 1024 byte packet
  1490. lengths above 2400 bps, 256 otherwise.
  1491.  
  1492. Because no time delays are necessary in normal file transfers, per
  1493. file negotiations are much faster than with YMODEM, the only observed
  1494. impidiment being the time required by the program(s) to update
  1495. logging files.
  1496.  
  1497. During a file transfer, a short line hit seen by the receiver usually
  1498. induces a CRC error.  The interrupt packet is usually seen by the
  1499. sender before the next packet is sent, and the resultant loss of data
  1500. throughput averages about half a packet.  At 1200 bps this is would
  1501. be about .75 second lost per hit.  At 10-5 error rate, this would
  1502. degrade throughput by about 9 per cent.  The throughput degradation
  1503. increases with the channel delay, as the packets in transit through
  1504. the channel are discarded on error.
  1505.  
  1506. A longer noise burst that affects both the receiver and the sender's
  1507. reception of the interrupt packet usually causes the sender to remain
  1508. silent until the receiver times out in 10 seconds.  If the round trip
  1509. channel delay exceeds the receiver's 10 second timeout, recovery from
  1510.  
  1511.  
  1512.  
  1513. Chapter 14        rev051486 Printed 5-16-86            23
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521. Chapter 14        rev051486 Printed 5-16-86            24
  1522.  
  1523.  
  1524.  
  1525. this type of error may become difficult.
  1526.  
  1527. Noise affecting only the sender is usually ignored, with one common
  1528. exception.  Spurious XOFF characters generated by noise stop the
  1529. sender until the receiver times out and sends an interrupt packet
  1530. which concludes with an XON.
  1531.  
  1532. In summation, ZMODEM performance in the presence of errors resembles
  1533. that of X.PC and SuperKermit.  Short bursts cause minimuml data loss.
  1534. Long bursts (such as pulse dialing noises) often require a timeout
  1535. error to restore the flow of data.
  1536.  
  1537.  
  1538. 15.  PACKET SWITCHED NETWORK CONSIDERATIONS
  1539.  
  1540. Flow control is necessary for printing messages and directories, and
  1541. for streaming file transfer protocols including Kermit Sliding
  1542. Windows and ZMODEM.  A non transparent flow control is incompatible
  1543. with XMODEM and YMODEM transfers.  XMODEM and YMODEM protocols
  1544. require complete transparency of all 256 8 bit codes to operate
  1545. properly.
  1546.  
  1547. The most desireable flow control (when X.25 or hardware CTS is
  1548. unavailable) does not "eat" any characters at all.  When the PAD's
  1549. buffer almost fills up, an XOFF should be emitted.  When the buffer
  1550. is no longer nearly full, send an XON.  Otherwise, the network should
  1551. neither generate nor eat XON or XOFF control characters.
  1552.  
  1553. On Telenet, this can be met by setting CCIT X3 5:1 and 12:0 at both
  1554. ends of the network.  For best throughput, parameter 64 (advance ACK)
  1555. should be set to something like 4.  Packets should be sent when the
  1556. packet is a full 128 bytes, or after a moderate delay (3:0,4:10,6:0).
  1557.  
  1558. For YMODEM, PAD buffering should guarantee that a minimum of 1040
  1559. characters can be sent in a burst without loss of data or generation
  1560. of flow control characters.  Failure to provide this buffering will
  1561. generate excessive retries with YMODEM.
  1562.  
  1563.           Figure 4.  Flow Control Compatibility
  1564.  
  1565.      Connectivity         Interactive   XMODEM    KERMIT     ZMODEM
  1566.  
  1567. Direct Connection         YES           YES    YES     YES
  1568. Network, no flow control     NO           YES    (1)     (1)
  1569. Network, transparent f.c.     YES           YES    YES     YES
  1570. Network, semi-transparent f.c.     YES           NO    YES     YES
  1571. Network, 7 bit             YES           NO    YES(2)     NO(3)
  1572.  
  1573. (1) Cannot operate in streaming mode.  Kermit is very slow because of
  1574. 96 byte max packet size.  ZMODEM can adjust burst length to maximum
  1575. for faster transfers.
  1576.  
  1577.  
  1578.  
  1579. Chapter 15        rev051486 Printed 5-16-86            24
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587. Chapter 15        rev051486 Printed 5-16-86            25
  1588.  
  1589.  
  1590.  
  1591. (2) Parity bits must be encoded, slowing binary transfers.
  1592.  
  1593. (3) Extension possible for encoding data to 7 bits.
  1594.  
  1595.  
  1596.  
  1597. 16.  PERFORMANCE COMPARISION TABLES
  1598.  
  1599.  
  1600. "Round Trip Delay Time" includes the time for the last byte in a
  1601. packet to propagate through the operating systems and network to the
  1602. receiver, plus the time for the receiver's response to that packet to
  1603. propogate back to the sender.
  1604.  
  1605. The figures shown below are calculated for round trip delay times of
  1606. 40 milliseconds and 5 seconds.  Shift registers in the two computers
  1607. and a pair of 212 modems generate a round trip delay time on the
  1608. order of 40 milliseconds.  Operation with busy timesharing computers
  1609. and networks can easily generate round trip delays of five seconds.
  1610. Because the round trip delays cause visible interruptions of data
  1611. transfer when using XMODEM protocol, the subjective effect of these
  1612. delays is greatly exaggerated, especially when the user is paying for
  1613. connect time.
  1614.  
  1615. A 102400 byte binary file with randomly distributed codes is sent at
  1616. 1200 bps 8 data bits, 1 stop bit.  The calculations assume no
  1617. transmission errors.  For each of the protocols, only the per file
  1618. functions are considered.  Processor and I/O overhead are not
  1619. included.  YM-k refers to YMODEM with 1024 byte packets.  YM-g refers
  1620. to the YMODEM "g" option.  ZMODEM uses 256 byte packets for this
  1621. example.  SuperKermit uses maximum packet size, 8 bit transparent
  1622. transmission, no run length compression.
  1623.  
  1624. For comparison, a straight "dump" of the file contents with no file
  1625. management or error checking takes 853 seconds.
  1626.  
  1627.          Figure 5.  Protocol Overhead Information
  1628.  
  1629.       Protocol        XMODEM     YM-k     YM-g    ZMODEM     S-Kermit
  1630.  
  1631. Protocol Round Trips    803     103     5    5     5
  1632. Trip Time at 40ms    32s     4s     0    0     0
  1633. Trip Time at 5s        4015s     515s     25s    25s     25
  1634.  
  1635. Overhead Characters    4803     603     503    3600     38280
  1636.  
  1637. Transfer Time at 0s    893s     858s     857s    883s     1172s
  1638. Transfer Time at 40ms    925s     862s     857s    883s     1172s
  1639. Transfer Time at 5s    5761s     1373s     882s    918s     1197s
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645. Chapter 16        rev051486 Printed 5-16-86            25
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653. Chapter 16        rev051486 Printed 5-16-86            26
  1654.  
  1655.  
  1656.  
  1657.          Figure 6.  Transmission Time Comparision
  1658.             (5 Second Round Trip)
  1659.  
  1660. ************************************************** XMODEM
  1661. ************ YMODEM-K
  1662. ********** SuperKermit (Sliding Windows)
  1663. ******* YMODEM-G
  1664. ******* ZMODEM
  1665.  
  1666.            Figure 7.  Y/ZMODEM Header Information usage
  1667.  
  1668.  
  1669.   Program     Batch   Length   Date   Mode   S/N   YMODEM-g   ZMODEM
  1670.  Unix rb/sb   yes     yes      yes    yes    no    sb only    no
  1671.  Unix rz/sz   yes     yes      yes    yes    no    sz only    yes
  1672.  VMS rb/sb    yes     yes      no     no     no    no          no
  1673.  Pro-YAM      yes     yes      yes    no     yes   yes          yes
  1674.  CP/M YAM     yes     no       no     no     no    no          no
  1675.  KMD/IMP      yes     yes-     no     no     no    no          no
  1676.  MEX          no      no       no     no     no    no          no
  1677.  
  1678.  
  1679. 17.  MORE INFORMATION
  1680.  
  1681. More information may be obtained by calling Telegodzilla at
  1682. 503-621-3746.
  1683.  
  1684. UUCP sites can obtain the nroff/troff source to this file with
  1685.           uucp omen!/usr/caf/public/zmodem.mm /tmp
  1686. A continually updated list of available files is stored in
  1687. /usr/spool/uucppublic/FILES.
  1688.  
  1689. The following L.sys line calls site "omen" yia UUCP.  Telegodzilla
  1690. uses Pro-YAM in host operation.
  1691.  
  1692. In response to "Name Please:" uucico gives the Pro-YAM "link" command
  1693. as a user name.  The password (Giznoid) controls access to the Xenix
  1694. system connected to the IBM PC's other serial port.  Communications
  1695. between Pro-YAM and Xenix use 9600 bps; YAM converts this to the
  1696. caller's speed.
  1697.  
  1698. Finally, the calling uucico logs in as uucp.
  1699.  
  1700.  omen Any ACU 1200 1-503-621-3746 e:--e: link d: Giznoid n:--n: uucp
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711. Chapter 18        rev051486 Printed 5-16-86            26
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719. Chapter 18        rev051486 Printed 5-16-86            27
  1720.  
  1721.  
  1722.  
  1723. 18.  ZMODEM PROGRAMS
  1724.  
  1725. A demonstration version of Professional-YAM is available as
  1726. YAMDEMO.ARC on TeleGodzilla..  This file must be unpacked with the
  1727. "ARC" program, version 5 or later.  A copy of ARC is available as
  1728. "ARC.EXE" or "ARC510.COM" on TeleGodzilla.
  1729.  
  1730.  
  1731. This may be used to test ZMODEM and YMODEM implementations.  A
  1732. flash-up tree structured help file and processor are provided in
  1733. YAMHELP.LQR.
  1734.  
  1735.  
  1736.  
  1737. 19.  YMODEM PROGRAMS
  1738.  
  1739. Unix programs supporting the YMODEM protocol are available on
  1740. Telegodzilla in the "upgrade" subdirectory as RBSB.SHQ (a SQueezed
  1741. shell archive).  Most Unix like systems are supported, including V7,
  1742. Sys III, 4.2 BSD, SYS V, Idris, Coherent, and Regulus.
  1743.  
  1744. A version for VAX-VMS is available in VRBSB.SHQ, in the same
  1745. directory.
  1746.  
  1747. Irv Hoff has added YMODEM 1k packets and YMODEM batch transfers to
  1748. the KMD and IMP series programs, which replace the XMODEM and
  1749. MODEM7/MDM7xx series respectively.  Overlays are available for a wide
  1750. variety of CP/M systems.
  1751.  
  1752. Many other programs, including MEX and MEX-PC also support some of
  1753. the YMODEM extensions.
  1754.  
  1755. Questions about YMODEM, the Professional-YAM communications program,
  1756. and requests for evaluation copies may be directed to:
  1757.  
  1758.      Chuck Forsberg
  1759.      Omen Technology Inc
  1760.      17505-V Sauvie Island Road
  1761.      Portland Oregon 97231
  1762.      Voice: 503-621-3406
  1763.      Modem (Telegodzilla): 503-621-3746
  1764.      Usenet: ...!tektronix!reed!omen!caf
  1765.      Compuserve: 70715,131
  1766.      Source: TCE022
  1767.  
  1768.                   Yours very truly,
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777. Chapter 19        rev051486 Printed 5-16-86            27
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.  
  1788.  
  1789.                   CONTENTS
  1790.  
  1791.  
  1792.  1.  INTENDED AUDIENCE................................................     2
  1793.  
  1794.  2.  ACKNOWLEDGMENTS..................................................     2
  1795.  
  1796.  3.  RELATED DOCUMENTS................................................     2
  1797.  
  1798.  4.  ROSETTA STONE....................................................     2
  1799.  
  1800.  5.  WHY DEVELOP ZMODEM?..............................................     3
  1801.  
  1802.  6.  ZMODEM Protocol Design Criteria..................................     5
  1803.      6.1    Ease of Use...............................................     5
  1804.      6.2    Throughput................................................     5
  1805.      6.3    Integrity and Robustness..................................     6
  1806.      6.4    Ease of Implementation....................................     6
  1807.  
  1808.  7.  ZMODEM BASICS....................................................     6
  1809.      7.1    Packetization.............................................     7
  1810.      7.2    Link Escape Encoding......................................     7
  1811.      7.3    Header Packet Information.................................     8
  1812.      7.4    Binary Header Packet......................................     9
  1813.      7.5    HEX Header Packet.........................................     9
  1814.      7.6    Binary Data Packets.......................................  10
  1815.      7.7    ASCII Encoded Data Packet.................................  10
  1816.  
  1817.  8.  PROTOCOL TRANSACTION OVERVIEW....................................  10
  1818.      8.1    Session Cancel Packet.....................................  13
  1819.  
  1820.  9.  ZMODEM STREAMING TECHNIQUES......................................  14
  1821.      9.1    Full Streaming with Sampling..............................  14
  1822.      9.2    Full Streaming with Interrupt.............................  14
  1823.      9.3    Full Streaming with a Sliding Window......................  15
  1824.      9.4    No Streaming..............................................  15
  1825.  
  1826. 10.  ATTENTION SEQUENCE...............................................  15
  1827.  
  1828. 11.  PACKET/FRAME TYPES...............................................  15
  1829.      11.1   ZRQINIT...................................................  16
  1830.      11.2   ZRINIT....................................................  16
  1831.      11.3   ZSINIT....................................................  16
  1832.      11.4   ZACK......................................................  16
  1833.      11.5   ZFILE.....................................................  16
  1834.      11.6   ZSKIP.....................................................  18
  1835.      11.7   ZNAK......................................................  18
  1836.      11.8   ZABORT....................................................  18
  1837.      11.9   ZFIN......................................................  18
  1838.      11.10  ZRPOS.....................................................  18
  1839.      11.11  ZDATA.....................................................  18
  1840.  
  1841.  
  1842.  
  1843.                   - i -
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853.  
  1854.  
  1855.      11.12  ZEOF......................................................  18
  1856.      11.13  ZFERR.....................................................  18
  1857.      11.14  ZCRC......................................................  18
  1858.      11.15  ZCHALLENGE................................................  19
  1859.      11.16  ZCOMPL....................................................  19
  1860.      11.17  ZCAN......................................................  19
  1861.      11.18  ZFREECNT..................................................  19
  1862.      11.19  ZCOMMAND..................................................  19
  1863.  
  1864. 12.  TRANSACTION EXAMPLE..............................................  20
  1865.      12.1   A simple file transfer....................................  20
  1866.      12.2   Challenge and Command Download............................  20
  1867.  
  1868. 13.  ZFILE FRAME FILE INFORMATION.....................................  21
  1869.  
  1870. 14.  PERFORMANCE RESULTS..............................................  23
  1871.      14.1   Throughput................................................  23
  1872.      14.2   Error Recovery............................................  23
  1873.  
  1874. 15.  PACKET SWITCHED NETWORK CONSIDERATIONS...........................  24
  1875.  
  1876. 16.  PERFORMANCE COMPARISION TABLES...................................  25
  1877.  
  1878. 17.  MORE INFORMATION.................................................  26
  1879.  
  1880. 18.  ZMODEM PROGRAMS..................................................  27
  1881.  
  1882. 19.  YMODEM PROGRAMS..................................................  27
  1883.  
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.                   - ii -
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.  
  1921.  
  1922.  
  1923.  
  1924.                  LIST OF FIGURES
  1925.  
  1926.  
  1927. Figure 1.  Order of Bytes in Header Packet............................     8
  1928.  
  1929. Figure 2.  Binary Header Packet.......................................     9
  1930.  
  1931. Figure 3.  HEX Header Packet..........................................  10
  1932.  
  1933. Figure 4.  Flow Control Compatibility.................................  24
  1934.  
  1935. Figure 5.  Protocol Overhead Information..............................  25
  1936.  
  1937. Figure 6.  Transmission Time Comparision..............................  26
  1938.  
  1939. Figure 7.  Y/ZMODEM Header Information usage..........................  26
  1940.  
  1941.  
  1942.  
  1943.  
  1944.  
  1945.  
  1946.  
  1947.  
  1948.  
  1949.  
  1950.  
  1951.  
  1952.  
  1953.  
  1954.  
  1955.  
  1956.  
  1957.  
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.                  - iii -
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985.      The ZMODEM Asynchronous Inter Application File Transfer Protocol
  1986.  
  1987.                   Chuck Forsberg
  1988.  
  1989.                Omen Technology Inc
  1990.  
  1991.  
  1992.                  ABSTRACT
  1993.  
  1994.  
  1995.  
  1996. The ZMODEM file transfer protocol greatly simplifies file transfers
  1997. compared to XMODEM.  In addition to supporting a transparent user
  1998. interface, ZMODEM provides Personal Computer and other users an efficient,
  1999. accurate, robust file transfer method.
  2000.  
  2001. ZMODEM provides especially efficient file transfers with timesharing
  2002. systems, satellite relays, and wide area packet switched networks.  A
  2003. choice of buffering and windowing modes allow ZMODEM to operate
  2004. efficiently on systems that cannot support some other streaming protocols.
  2005.  
  2006. ZMODEM provides advanced file management features including AutoDownload,
  2007. remote file compare, aborted transfer recovery, selective file transfers,
  2008. and security verified command downloading.
  2009.